package com.androidx.p013lv.mine.fragment;

import android.os.Bundle;
import android.view.View;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.adapter.SquareAdapter;
import com.androidx.p013lv.base.bean.OfficialBean;
import com.androidx.p013lv.base.bean.OfficialListBean;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.listener.ItemClickListener;
import com.androidx.p013lv.base.model.SquareModel;
import com.androidx.p013lv.base.p015ui.LazyFragment;
import com.androidx.p013lv.base.utils.NetUtil;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.androidx.p013lv.mine.C1207R;
import com.androidx.p013lv.mine.databinding.FragmentAboutHerAttentionBinding;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;

/* renamed from: com.androidx.lv.mine.fragment.AboutHerAttentionFragment */
public class AboutHerAttentionFragment extends LazyFragment<FragmentAboutHerAttentionBinding> implements OnRefreshLoadMoreListener, ItemClickListener {
    SquareAdapter adapter;
    boolean isResume = false;
    SquareModel model;
    int page = 1;

    public static AboutHerAttentionFragment newInstance() {
        Bundle bundle = new Bundle();
        AboutHerAttentionFragment aboutHerAttentionFragment = new AboutHerAttentionFragment();
        aboutHerAttentionFragment.setArguments(bundle);
        return aboutHerAttentionFragment;
    }

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment
    public int setFragmentView() {
        return C1207R.C1212layout.fragment_about_her_attention;
    }

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment
    public void initViews() {
        SquareModel squareModel = (SquareModel) new ViewModelProvider(this).get(SquareModel.class);
        this.model = squareModel;
        squareModel.getAttention().observe(this, new Observer<BaseRes<OfficialListBean>>() {
            /* class com.androidx.p013lv.mine.fragment.AboutHerAttentionFragment.C13051 */

            public void onChanged(BaseRes<OfficialListBean> baseRes) {
                ((FragmentAboutHerAttentionBinding) AboutHerAttentionFragment.this.binding).statusLayout.hideLoading();
                ((FragmentAboutHerAttentionBinding) AboutHerAttentionFragment.this.binding).refresh.finishRefresh();
                ((FragmentAboutHerAttentionBinding) AboutHerAttentionFragment.this.binding).refresh.finishLoadMore();
                if (baseRes.getCode() == 200) {
                    if (baseRes.getData() != null && baseRes.getData().getList() != null && baseRes.getData().getList().size() > 0) {
                        if (AboutHerAttentionFragment.this.page == 1) {
                            AboutHerAttentionFragment.this.adapter.setDomain(baseRes.getData().getDomain());
                            AboutHerAttentionFragment.this.adapter.setData(baseRes.getData().getList());
                            ((FragmentAboutHerAttentionBinding) AboutHerAttentionFragment.this.binding).refresh.resetNoMoreData();
                        } else {
                            AboutHerAttentionFragment.this.adapter.setDatasInEnd(baseRes.getData().getList());
                        }
                        AboutHerAttentionFragment.this.page++;
                    } else if (AboutHerAttentionFragment.this.page == 1) {
                        ((FragmentAboutHerAttentionBinding) AboutHerAttentionFragment.this.binding).statusLayout.showEmpty();
                    } else {
                        ((FragmentAboutHerAttentionBinding) AboutHerAttentionFragment.this.binding).refresh.finishLoadMoreWithNoMoreData();
                    }
                } else if (AboutHerAttentionFragment.this.page == 1) {
                    ((FragmentAboutHerAttentionBinding) AboutHerAttentionFragment.this.binding).statusLayout.showError();
                } else {
                    ToastUtils.getInstance().showWeak(baseRes.getMsg());
                }
            }
        });
        ((FragmentAboutHerAttentionBinding) this.binding).refresh.setOnRefreshListener(this);
        ((FragmentAboutHerAttentionBinding) this.binding).refresh.setOnLoadMoreListener(this);
        this.adapter = new SquareAdapter(true);
        ((FragmentAboutHerAttentionBinding) this.binding).recycler.setLayoutManager(new LinearLayoutManager(getContext()));
        ((FragmentAboutHerAttentionBinding) this.binding).recycler.setAdapter(this.adapter);
        this.adapter.setItemListener(this);
        ((FragmentAboutHerAttentionBinding) this.binding).statusLayout.setOnRetryListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.mine.fragment.AboutHerAttentionFragment.View$OnClickListenerC13062 */

            public void onClick(View view) {
                AboutHerAttentionFragment.this.page = 1;
                AboutHerAttentionFragment.this.getInfo();
            }
        });
        getInfo();
    }

    @Override // androidx.fragment.app.Fragment, com.gyf.immersionbar.components.ImmersionFragment
    public void onResume() {
        super.onResume();
        this.isResume = true;
    }

    @Override // androidx.fragment.app.Fragment, com.gyf.immersionbar.components.ImmersionFragment
    public void onPause() {
        super.onPause();
        this.isResume = false;
    }

    /* access modifiers changed from: package-private */
    public void getInfo() {
        if (this.page == 1) {
            SquareAdapter squareAdapter = this.adapter;
            if (!(squareAdapter == null || squareAdapter.getData() == null || this.adapter.getData().size() <= 0)) {
                this.adapter.clear();
            }
            if (!NetUtil.isNetworkAvailable()) {
                ((FragmentAboutHerAttentionBinding) this.binding).statusLayout.showNoNet();
                return;
            }
            ((FragmentAboutHerAttentionBinding) this.binding).statusLayout.showLoading();
        }
        this.model.getAttention(this.page);
    }

    @Override // com.androidx.p013lv.base.listener.ItemClickListener
    public void onItemClick(View view, int i) {
        if (!isOnClick()) {
            ARouter.getInstance().build(Constance.USER_INFO_ACTIVITY).withInt(Key.USER_ID, ((OfficialBean) this.adapter.getDataInPosition(i)).getBeenUserId()).navigation();
        }
    }

    @Override // com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
    public void onLoadMore(RefreshLayout refreshLayout) {
        SquareAdapter squareAdapter = this.adapter;
        if (squareAdapter == null || squareAdapter.getData() == null || this.adapter.getData().size() == 0) {
            ((FragmentAboutHerAttentionBinding) this.binding).refresh.finishLoadMore();
        } else {
            getInfo();
        }
    }

    @Override // com.scwang.smartrefresh.layout.listener.OnRefreshListener
    public void onRefresh(RefreshLayout refreshLayout) {
        this.page = 1;
        getInfo();
    }

    @Override // androidx.fragment.app.Fragment, com.gyf.immersionbar.components.ImmersionFragment
    public void onDestroy() {
        super.onDestroy();
        SquareModel squareModel = this.model;
        if (squareModel != null) {
            squareModel.cancelHttp();
        }
    }
}
